#pragma once
#include <Rz/Object.h>
#include <Rz/Graphics/Render/IEffect.h>
#include <Rz/Graphics/Render/IEffectProperty.h>
#include "GL.h"

namespace Rz { namespace Graphics { namespace Render { namespace Libraries { namespace OpenGL {

class GLEffect :
	public Object,
	public IEffect
{
	friend class GLEffectProperty;

	public:
		RZ_RTTI(Rz::Graphics::Render::Libraries::OpenGL, GLEffect);
		RZ_RTTI_IMPLEMENTS(Object, IEffect);
		RZ_RTTI_END;

		GLEffect(IRenderDevice* renderDevice);
		GLEffect(IRenderDevice* renderDevice, const String& shader);
		~GLEffect();

		void virtual Bind() override;
		void virtual Unbind() override;

		void virtual Init(const String& shader) override;

		virtual IEffectProperty* CreateAndAddProperty(const String& name) override;

		u32 virtual FindUniformIndex(const String& name) const override;
		
	private:
		void Debug(GLuint object, const char* type);
		GLenum GetNextUnitID();
		void ResetUnitCounter();
		
		String _vertShader;
		String _pixShader;

		GLuint _vertShaderHandle;
		GLuint _pixShaderHandle;
		GLuint _programHandle;

		GLenum _unitCounter;
};

} } } } }

#undef RZ_GL_PRINTSTATUS

